<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js"></script>
<script src="../sources/js/cookie.js"></script>
</head>
<body>
<div class="box" style="width:40%;height:400px;background-color:#aaa;margin:auto;margin-top:110px;">
<h4 style="text-align:center">用户名</h4>
<input type="text" id="userName" style="width:50%;height:40px;margin:0 25%;"></input>
<h3 style="text-align:center">密码</h3>
<input type="text" id="password" style="width:50%;height:40px;margin:0 25%;"></input>
<input type="button" id="btn" value="登录" onclick="get()" style="width:50%;height:40px;margin:30px 25%"/>
</div>
</body>
 <script>
function get(){
	var data={
			"userName":$("#userName").val(),
			"password":$("#password").val()	
	};
	var url="http://localhost:8080/maven02/user/login";
	$.ajax({
		type:"get",
		url:url,
	 	data:data,
	 	dataType:"JSON",
	success:function(data){
		setCookie("userName",data.userName,3);
		console.log(data);
		alert("登录成功");
		if(data.userName == "admin"){
			window.location.href = "back.html";
		}else {
			window.location.href = "seleA.html";
		}
	},
	error:function(){
		alert(typeof(errorThrown));
	}
	});
}
</script>
</html>